import { Router } from "express";
import { CapCallbackFn } from "../../type";

export default (router: Router, callbackFn: CapCallbackFn) => {
  router.post("/getconsumeset", (req, res) => {
     let {username} = req.body
     let sql = `select * from RecordConsumeCode where username = '${username}' order by cateorder`
     callbackFn(res,{sql})
  });   

  router.post("/setconsumeset",(req,res)=>{
    let {username,setlist} = req.body
    let sql = `delete from RecordConsumeCode where username = '${username}'`
    console.log("12313")
    setlist.forEach((item:any) => {
        //
        sql +=`insert into RecordConsumeCode values ('${username}',${item.code},'${item.desc}',${item.cateorder});`
    });
    callbackFn(res,{sql})
  })
  return router;

};
